<?php
namespace View;


class LoginView {
	
	private $m_userKey = "userName";
	private $m_passKey = "password";
	private $m_logoutKey = "logout";
	//private $m_loginBtnKey = "loginBtn";
	
	public function DoLoginBox(){
		$xhtml =	"
					<form method='GET'>
					<fieldset>
					<legend>Inloggning</legend>
					<label>Namn:</label>
					<input type='text' name='".$this->m_userKey."'/>
					<label>Lösen:</label>
					<input type='password' name='".$this->m_passKey."' />
					<input type='submit' value='Logga in!' />
					</fieldset>
					</form>
					";
		return $xhtml;
	}
	
	public function DoLogoutBox(){
		$xhtml = 	"
					<form method='GET'>
					<input type='hidden' name='".$this->m_logoutKey."' value='true' />
					<input type='submit' value='Logga ut!' />
					</form>
					";
		return $xhtml;
	}
	
	public function GetUserName(){
		if (isset( $_GET[$this->m_userKey]) == true) {
			return $_GET[$this->m_userKey];
		}
		return NULL;
	}
	
	public function GetPassword(){
		if (isset( $_GET[$this->m_passKey]) == true) {
			return $_GET[$this->m_passKey];
		}
		return NULL;
	}
	
	public function TriedToLogin(){
		if( $this->GetUserName() !=NULL && $this->GetPassword() != NULL){
			return true;
		}else{
			return false;
		}
		
	}
	
	public function TriedToLogout(){
		if(isset($_GET[$this->m_logoutKey])){
			return true;
		}else{
			return false;
		}
		
	}
}
?>